import socket

# 创建TCP socket对象
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 连接服务器
client_socket.connect(('localhost', 8000))

# 发送数据给服务器
client_socket.sendall('Hello, server!'.encode())

# 接收服务器响应数据
data = client_socket.recv(1024)
print('Received message:', data.decode())

# 关闭连接
client_socket.close()
